package com.aube.rvi;

/**
 * Created by huyaonan on 16/10/25.
 */
public class ImageParamUtils {

    public static String getImgUrl(String url, int w, int h) {
        if(!url.contains("aube-tv"))
            return url;
        return getImgUrl(url, w, h, 0, 0);
    }

    public static String getImgUrl(int w, int h) {
        return getImgUrl(w, h, 0, 0);
    }

    /**
     * @param w
     * @param h
     * @param radius
     * @param sigma
     * @return @100w_100h_1e_1c_3-2bl
     */
    public static String getImgUrl(int w, int h, int radius, int sigma) {
        StringBuffer sb = new StringBuffer();
        sb.append("@").append(w).append("w_").append(h).append("h");
        if(radius == 0 || sigma == 0)
            return sb.toString();
        return sb.append("_").append(radius).append("-").append(sigma).append("bl").toString();
    }

    public static String getImgUrl(String url, int w, int h, int radius, int sigma) {
        if(w == 0 || h == 0)
            return url;
        StringBuffer sb = new StringBuffer();
        if(url.contains("@"))
            sb.append(url.substring(0, url.indexOf("@")));
        else
            sb.append(url);
        sb.append("@").append(w).append("w_").append(h).append("h");
        if(radius == 0 || sigma == 0)
            return sb.toString();
        String result = sb.append("_").append(radius).append("-").append(sigma).append("bl").toString();
        return result;
    }

}
